function show_canshu(){
    var grid;
    var record;
    var paraidd;
    Ext.state.Manager.setProvider(
        new Ext.state.SessionProvider({
            state: Ext.appState
            })
        );
       
    Ext.QuickTips.init();
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    var xg = Ext.grid;  
    var re = Ext.ComponentMgr.get("ggg").getSelectionModel().getSelected();
	if (re == null || re == "") {
		Ext.Msg.alert('提示', '请选择需要关联的指标！');
	} else{
    var openUrl = basePath
    + 'JarpListener?className=cn.com.jsepc.rep.report.reportGrid';
    openUrl += '&methodName=getReportGrid&paramCount=1'+'&param_0='+re.data.repid;  
   
    var jReader1 = new Ext.data.JsonReader({
        fields : [{
            name : 'paraid'
        },{
            name : 'repid'
        },{
            name:'paraname'
        },{
            name:'sourcedep'
        },{
            name:'contactor'
        },{
            name:'paraunit'
        },{
            name:'updatatime'
        },{
            name:'issaved'
        }]
    });
	
    var store = new Ext.data.Store({
        autoLoad:true,
        url:openUrl,
        reader : jReader1
    });
       
    store.setDefaultSort('paraid', 'ASC');
    var sm = new xg.CheckboxSelectionModel({
        singleSelect : true,
        listeners: {
            selectionchange: function(sm) {
                if (sm.getCount()) {
                    var selections = grid.getSelectionModel().getSelections();
                    for(var i=0;i<selections.length;i++)
                    {
                        record=selections[i];
                    }                  
                    paraidd=record.get("paraid");
                } else {
                }
            }
        }
    });
	
    var cm = new xg.ColumnModel( [
        sm,							
        {
            hidden:true,
            id : 'paraid1',
            name       :'paraid1',
            header   : '参数编号', 
            sortable : true, 
            dataIndex: 'paraid'
        },
        {
            id:'repid',
            name       :'repid',
            header   : '所属指标',
            sortable : true, 
            dataIndex: 'repid',
        	hidden:true
        },{
            id : 'paraname',
            name       :'paraname',
            header   : '参数名称', 
            sortable : true, 
            dataIndex: 'paraname'
        },{
            id : 'sourcedep',
            name       :'sourcedep',
            header   : '来源部门', 
            sortable : true, 
            dataIndex: 'sourcedep'
        },{
            id : 'contactor',
            name       :'contactor',
            header   : '联络人', 
            sortable : true, 
            dataIndex: 'contactor'
        },{
            id : 'paraunit',
            name       :'paraunit',
            header   : '参数单位', 
            sortable : true, 
            dataIndex: 'paraunit'
        },{
            hidden:true,
            id : 'updatatime',
            name       :'updatatime',
            header   : '更新频率', 
            sortable : true, 
            dataIndex: 'updatatime',
            renderer : function(v){
                if(v==1) {
                    return "年";
                }else if(v==2) {
                    return "季";
                }else if(v==3){
                    return "月";
                }else if(v==4){
                    return "周";
                }
                else if(v==5){
                    return "日";
                }
                else if(v==6){
                    return "时";
                }
            }
        },{
            hidden:true,
            id : 'issaved',
            name       :'issaved',
            header   : '是否存在',   
            sortable : true, 
            dataIndex: 'issaved',
            renderer : function(v){
                if(v==0) {
                    return "不存在";
                }else if(v==1) {
                    return "存在";
                }
            }
        }
        ]);
	     
    cm.defaultSortable = true;
    grid = new Ext.grid.GridPanel({
        id:'crp',
        region: 'center',
        viewConfig: {
            forceFit: true
        }, 
        store:store,
        sm:sm,
        cm:cm,  
        columnLines:true,
        height: 305,
        width: 245,
        stateful: true,
        stateId: 'grid'
    }); 
    
    var win = new Ext.Window({
        
        title: '指标参数信息',           
        closable:true,
        width:600,
        height:370,
        modal:true,
        plain:true,
        layout: 'border',
         tbar : ['-', 
        {
            text:'新增',
            handler : function() {
                        	 show_win();
          }
        
        },'-',{
            text:'编辑',
            handler : function(){
                    var checkse= Ext.ComponentMgr.get("crp").getSelectionModel().getSelected();
                    if(checkse == null  || checkse == "")
                    {
                        Ext.Msg.alert('提示','请勾选需要编辑的指标！');
                    }else{
                        show_win(); 
                        Ext.getCmp("paraid").setValue(record.get("paraid"));
                        Ext.getCmp("repid").setValue(record.get("repid"));
                        Ext.getCmp("paraname").setValue(record.get("paraname"));
                        Ext.getCmp("sourcedep").setValue(record.get("sourcedep"));
                        Ext.getCmp("contactor").setValue(record.get("contactor"));
                        Ext.getCmp("paraunit").setValue(record.get("paraunit"));
                        Ext.getCmp("updatatime").setValue(record.get("updatatime"));
                        Ext.getCmp("issaved").setValue(record.get("issaved"));
                    }
                }
        },'-',{
            text:'删除',
            handler : function() {
                    var checkse= Ext.ComponentMgr.get("crp").getSelectionModel().getSelected();

                    if(checkse == null  || checkse == "")
                    {
                        Ext.Msg.alert('提示','请勾选需要删除的指标！');
                    }else{
                          deleteFrom();
                    }
                }  
            },'-',{
            	text:'关闭',
            	handler:function(){
            		win.close();
            	}
            }
        ],
        items: [grid]
    });
    
    //删除
    function  deleteFrom() {
        Ext.MessageBox.show({
            title:'提示框',
            msg: ' 确定删除吗',                
            buttons:{
                'yes':'确定',
                'no': '取消'
            },
            fn: showResult,
            icon: Ext.MessageBox.QUESTION
        });
        function showResult(btn){
            if(btn == 'yes'){ 
               var saveItemInfoUrl = "";
               saveItemInfoUrl = '?className=cn.com.jsepc.rep.report.reportGrid';
               saveItemInfoUrl += '&methodName=ReportDelete';
               saveItemInfoUrl += '&paramCount=1'+'&param_0='+paraidd;

               saveItemInfoUrl = basePath + 'JarpListener' + saveItemInfoUrl;
               httpR_itemInfo = getXMLHttpRequest();
               httpR_itemInfo.onreadystatechange = returnDelete;
               httpR_itemInfo.open("POST", saveItemInfoUrl, true);
               httpR_itemInfo.send();
            }else if( btn == 'no')
            {
                return;
            }
        }       
    }
    function returnDelete() {
        if (httpR_itemInfo.readyState == 4) {
            if (httpR_itemInfo.status == 200) {
                var ret = httpR_itemInfo.responseText;
                if (ret=='true'){
                    Ext.MessageBox.show({
                            title:'提示框',
                            msg: ' 删除成功 ',                
                            buttons:{
                                'yes':'确定'
                            },
                            fn: showResult2
                        });
                        function showResult2(btn){
                            if(btn=="yes"){
                                grid.store.reload();
                            }
                      } 
                }else if(ret="false"){
                    Ext.Msg.alert('提示','删除失败！');
                }
            }
        }
    }
   
    function  datastore(){
    	
        formStore.paraid = Ext.ComponentMgr.get("paraid").getValue();
        formStore.repid = Ext.ComponentMgr.get("repid").getValue();
        formStore.paraname = Ext.ComponentMgr.get("paraname").getValue();
        formStore.sourcedep = Ext.ComponentMgr.get("sourcedep").getValue();
        formStore.contactor = Ext.ComponentMgr.get("contactor").getValue();
        formStore.paraunit = Ext.ComponentMgr.get("paraunit").getValue();
        formStore.updatatime = Ext.ComponentMgr.get("updatatime").getValue();
        formStore.issaved = Ext.ComponentMgr.get("issaved").getValue();

    }		
    
    function  clearstore(){
    	
        Ext.ComponentMgr.get("paraid").setValue("");
        Ext.ComponentMgr.get("repid").setValue("");
        Ext.ComponentMgr.get("paraname").setValue("");
        Ext.ComponentMgr.get("sourcedep").setValue("");
        Ext.ComponentMgr.get("contactor").setValue("");
        Ext.ComponentMgr.get("paraunit").setValue("");
        Ext.ComponentMgr.get("updatatime").setValue("");
        Ext.ComponentMgr.get("issaved").setValue("");

    }
    
    win.show(this);

    }
    
    
    //保存窗口
    function show_win(){
	
    Ext.QuickTips.init();  
    Ext.form.Field.prototype.msgTarget = 'side';
    var bd = Ext.getBody();
    var re = Ext.ComponentMgr.get("ggg").getSelectionModel().getSelected();
    var fsf = new Ext.FormPanel({
        labelWidth: 150, 
        frame:true,
        bodyStyle:'padding:5px 7px 0',
        width: 460,
        height:310, 
        region: 'center',
        defaults: {
            width: 210
        },
        defaultType: 'textfield',           
        items :[{
            xtype : 'hidden',
            id: 'paraid',
            fieldLabel: '参数编号',
            name: 'paraid',
            blankText:'此项必填',
            allowBlank : false,
            emptyText : '请输入参数编号'
        },{
        	xtype:'hidden',
            id: 'repid',
            fieldLabel: '所属指标',
            name: 'repid',
            blankText:'此项必填，只能输入数字',
            allowBlank : false,
            emptyText : '请输入所属指标'
           // xtype : 'numberfield'
        },{
            id: 'paraname',
            fieldLabel: '参数名称 ',
            name: 'paraname',
            blankText:'此项必填',
            allowBlank : false,
            emptyText : '请输入参数名称'
        },{
            id: 'sourcedep',
            fieldLabel: '来源部门',
            name: 'sourcedep',
            blankText:'此项必填',
            allowBlank : false,
            emptyText : '请输入来源部门'
        },{
            id: 'contactor',
            fieldLabel:'联系人',
            name: 'contactor',
            blankText:'此项必填',
            allowBlank : false,
            emptyText : '请输入联系人'
        },{
            id: 'paraunit',
            fieldLabel:'参数单位',
            name: 'paraunit',
            blankText:'此项必填',
            allowBlank : false,
            emptyText : '请输入参数单位'
        },
         new Ext.form.ComboBox( {
            fieldLabel : "更新频率",
            emptyText : '请选择更新频率',
            blankText:'此项必选',
            id : 'updatatime',
            editable : false,
            triggerAction : 'all',
            store:[
                        ['1','年'],
                        ['2','季'],
                        ['3','月'],
                        ['4','周'],
                        ['5','日'],
                        ['6','时']
                    ],
            mode : 'remote',
            valueField : 'value',
            displayField : 'text'
        }) ,
          new Ext.form.ComboBox( {
            fieldLabel : "是否存在",
            emptyText : '请选择是否存在',
            blankText:'此项必选',
            id : 'issaved',
            editable : false,
            triggerAction : 'all',
            store:[
                        ['0','不存在'],
                        ['1','存在']
                    ],
            mode : 'remote',
            valueField : 'value',
            displayField : 'text'
        }) 
        ]
       
    });
   
    var win1 = new Ext.Window({
            
        title: '指标参数信息',            
        closable:true,
        width:460,
        height:350,
        plain:true,
        modal:true,//控制增加按钮两次弹出
        layout: 'border',
        tbar : ['-', 
       {
            text:'保存',
            handler : function() {
                saveForm();		
            }
        },'-',{
            text:'关闭',
            handler : function() {
                win1.close();
            }
        }
        ],
        items: [fsf]
    });  
    
        
    win1.show(this);
     
    Ext.ComponentMgr.get("repid").setValue(re.data.repid);
    formStore = new Ext.data.Store(['paraid', 'repid','paraname','sourcedep','contactor','paraunit','updatatime ','issaved']);
    
        //保存
    function saveForm() {	
        var paraid=Ext.ComponentMgr.get("paraid").getValue();
        if( paraid == ""){
            gvalue();
            var saveItemInfoUrl = "";
            saveItemInfoUrl = '?className=cn.com.jsepc.rep.report.reportGrid';
            saveItemInfoUrl += '&methodName=ReportAdd';
            saveItemInfoUrl += '&paramCount=0';

            saveItemInfoUrl = basePath + 'JarpListener' + saveItemInfoUrl;
            httpR_itemInfo = getXMLHttpRequest();
            httpR_itemInfo.onreadystatechange = returnItemAdd;
            httpR_itemInfo.open("POST", saveItemInfoUrl, true);
            httpR_itemInfo.send(Ext.util.JSON.encode(formStore));
            
        }else if( paraid != ""){
            gvalue();
            var saveItemInfoUrl = "";
            saveItemInfoUrl = '?className=cn.com.jsepc.rep.report.reportGrid';
            saveItemInfoUrl += '&methodName=ReportUpdate';
            saveItemInfoUrl += '&paramCount=0';

            saveItemInfoUrl = basePath + 'JarpListener' + saveItemInfoUrl;
            httpR_itemInfo = getXMLHttpRequest();
            httpR_itemInfo.onreadystatechange = returnItemUpdate;
            httpR_itemInfo.open("POST", saveItemInfoUrl, true);
            httpR_itemInfo.send(Ext.util.JSON.encode(formStore));
        }
    }
    function returnItemAdd() {
        if (httpR_itemInfo.readyState == 4) {
            if (httpR_itemInfo.status == 200) {
                var res = httpR_itemInfo.responseText;
                 if (res=="true"){            
                    Ext.MessageBox.show({
                        title:'提示框',
                        msg: ' 保存成功',                
                         buttons:{
                            'yes':'确定'
                        },
                        fn: showResult
            
                     });
                     function showResult(btn){
                            if(btn == 'yes'){ 
                                 Ext.ComponentMgr.get("paraid").setValue("");
                                 Ext.ComponentMgr.get("repid").setValue("");
                                 Ext.ComponentMgr.get("paraname").setValue("");
                                 Ext.ComponentMgr.get("sourcedep").setValue("");
                                 Ext.ComponentMgr.get("contactor").setValue("");
                                 Ext.ComponentMgr.get("paraunit").setValue("");
                                 Ext.ComponentMgr.get("updatatime").setValue("");
                                 Ext.ComponentMgr.get("issaved").setValue("");          
                            }
                            win1.close();                      
                     }
                    grid.store.reload();   
                }else {
                     Ext.Msg.alert('提示','保存失败！');
                }
            }
        }
    }
    
    
    
       function returnItemUpdate() {
        if (httpR_itemInfo.readyState == 4) {
            if (httpR_itemInfo.status == 200) {
                var res = httpR_itemInfo.responseText;
                 if (res=="true"){ 
                       Ext.MessageBox.show({
                            title:'提示框',
                            msg: ' 保存成功 ',                
                            buttons:{
                                'yes':'确定'
                            },
                            fn: showResult1
                        });
                        function showResult1(btn){
                            if(btn=="yes"){
                                Ext.ComponentMgr.get("paraid").setValue("");
                                Ext.ComponentMgr.get("repid").setValue("");
                                Ext.ComponentMgr.get("paraname").setValue("");
                                Ext.ComponentMgr.get("sourcedep").setValue("");
                                Ext.ComponentMgr.get("contactor").setValue("");
                                Ext.ComponentMgr.get("paraunit").setValue("");
                                Ext.ComponentMgr.get("updatatime").setValue("");
                                Ext.ComponentMgr.get("issaved").setValue("");                         
                            }
                            win1.close();
                        }
                        grid.store.reload();
                }else{
                     Ext.Msg.alert('提示','保存失败！');
                }
            }
        }
    }
    
    
    
    function gvalue(){
        var paraid=Ext.ComponentMgr.get("paraid").getValue();
        var repid=Ext.ComponentMgr.get("repid").getValue();
        var paraname=Ext.ComponentMgr.get("paraname").getValue();
        var sourcedep=Ext.ComponentMgr.get("sourcedep").getValue();
        var contactor=Ext.ComponentMgr.get("contactor").getValue();
        var paraunit=Ext.ComponentMgr.get("paraunit").getValue();
        var updatatime=Ext.ComponentMgr.get("updatatime").getValue();
        var issaved=Ext.ComponentMgr.get("issaved").getValue();
        
        if( repid == null  || repid == ""){
             Ext.Msg.alert('提示','所属指标不能为空！');
        }else if(paraname == null  || paraname == ""){
             Ext.Msg.alert('提示','参数名称不能为空！');
        }else if(sourcedep == null  || sourcedep == ""){
             Ext.Msg.alert('提示','来源部门不能为空！');
        }else if(contactor == null  || contactor == ""){
             Ext.Msg.alert('提示','联系人不能为空！');
        }else if(paraunit == null  || paraunit == ""){
             Ext.Msg.alert('提示','参数单位不能为空！');
        }else if(updatatime == null  || updatatime == ""){
             Ext.Msg.alert('提示','更新频率不能为空！');
        }else if(issaved == null  || issaved == ""){
             Ext.Msg.alert('提示','是否存在不能为空！');
        }else{           
            formStore.paraid = paraid;
            formStore.repid = repid;
            formStore.paraname = paraname;
            formStore.sourcedep = sourcedep;
            formStore.contactor = contactor;
            formStore.paraunit = paraunit;
            formStore.updatatime = updatatime;
            formStore.issaved = issaved;
        }
    }

}

}